package com.pan.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public enum ApplicationConfig {
    INSTANCE;
    private final String applicationConfigPath = "application.properties";

    private Properties properties;

    {
        InputStream configInputStream = ClassLoader
                .getSystemResourceAsStream(applicationConfigPath);
        properties = new Properties();
        try {
            properties.load(configInputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

    private String getValue(String key) {
        String value = properties.getProperty(key);
        if (value == null) {
            throw new RuntimeException("ApplicationConfig Error: I don't know this " + key);
        }
        return value;
    }

    public String getExecutiveFactoryName() {
        return getValue("zzz11fire.executive.factory");
    }

    public String getExecutiveDriverName() {
        return getValue("zzz11fire.executive.driver");
    }

    public String getScriptTranslatorName() {
        return getValue("zzz11fire.script.translator");
    }

    public String getEventListenerName() {
        return getValue("zzz11fire.event.listener");
    }


}
